﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class GroupProductDAL : SqlDataProvider
	{

		#region[GroupProduct_GetbyAll]
		public DataTable GroupProduct_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[GroupProduct_GetbyId]
		public DataTable GroupProduct_GetById(string Id)
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Id));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[GroupProduct_GetbyTop]
		public DataTable GroupProduct_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[GroupProduct_Insert]
		public void GroupProduct_Insert(GroupProductInfo Data)
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Images", Data.Images));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[GroupProduct_Update]
		public void GroupProduct_Update(GroupProductInfo Data)
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Images", Data.Images));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[GroupProduct_Delete]
        public void GroupProduct_Delete(string Id)
		{
			using (var cmd = new SqlCommand("sp_GroupProduct_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Id", Id));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}